package com.cqz.action;

import com.cqz.dao.OrderInfo;
import com.cqz.services.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

/***
 * 对应的删除操作
 */
@Controller
public class DeleteAction {
    @Autowired
    private OrderService orderService;

    /**
     * 批量删除购物车信息
     * @param httpSession
     * @param bid
     * @return
     */
    @RequestMapping("deleteShopTrolleyItemAction")
    public String deleteShopTrolleyItemAction(HttpSession httpSession,String bid){
        int uid=(Integer)httpSession.getAttribute("uid");
        String[]bids=bid.split(",");
        int len=bids.length;
        OrderInfo orderInfo=new OrderInfo();
        orderInfo.setOstate("未付款");
        orderInfo.setUid(uid);
        for(int i=0;i<len;i++){
            orderInfo.setBid(Integer.parseInt(bids[i]));
            orderService.deleteByBid(orderInfo);
        }
        return "redirect:searchShopTrolleyAction";
    }
}
